package com.hzeport.bgs22emduty.inbound.api;

import com.hzeport.bgs22emduty.config.login.LoginCompoentService;
import com.hzeport.bgs22emduty.config.login.UserInfoDetailVO;
import com.hzeport.bgs22emduty.config.systemLog.OperLog;
import com.hzeport.bgs22emduty.dto.ScreenEmergencyPlanDTO;
import com.hzeport.bgs22emduty.dto.ScreenNoticeDTO;
import com.hzeport.bgs22emduty.dto.messgeDistribute.ScreenMessageDistributeHideDTO;
import com.hzeport.bgs22emduty.entity.ScreenEmergencyPlan;
import com.hzeport.bgs22emduty.entity.ScreenStandard;
import com.hzeport.bgs22emduty.enums.HideStatusEnum;
import com.hzeport.bgs22emduty.vo.ScreenNotice.ScreenNoticeListVO;
import com.hzeport.bgs22emduty.vo.ScreenNotice.ScreenNoticeSaveVO;
import com.hzeport.bgs22emduty.vo.ScreenNotice.postarticlesVO;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzeport.bgs22emduty.entity.ScreenNotice;
import com.hzeport.bgs22emduty.service.ScreenNoticeService;
//import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * ${comments}
 *
 * @author code generator
 * @date 2023-02-14 09:39:44
 */
@RestController
@AllArgsConstructor
@RequestMapping("/screennotice")
@Api(value = "screennotice", tags = "值班通知管理")
@Slf4j
public class ScreenNoticeController {

    private final ScreenNoticeService screenNoticeService;

    @Resource
    private final LoginCompoentService loginCompoentService;

    @ApiOperation(value = "列表")
    @RequestMapping(value = "list",method = RequestMethod.POST)
    public  BaseResult<Page<ScreenNoticeListVO>> list(@RequestBody ScreenNoticeDTO dto) {
        UserInfoDetailVO userInfoDetailVO=loginCompoentService.getUserInfo();
        return  screenNoticeService.list(dto,userInfoDetailVO);
    }

    @ApiOperation(value = "删除")
    @RequestMapping(value = "delete",method = RequestMethod.POST)
    @OperLog( systemName = "ZBTZ", description = "TZSC")
    public BaseResult removeById(@RequestParam("id") String id) {
        UserInfoDetailVO userInfoDetailVO=loginCompoentService.getUserInfo();
        return screenNoticeService.delete(id,userInfoDetailVO);
    }

    @ApiOperation(value = "保存")
    @RequestMapping(value = "save",method = RequestMethod.POST)
    @OperLog( systemName = "ZBTZ", description = "TZBC")
    public BaseResult save(@RequestBody ScreenNoticeSaveVO screenNoticeSaveVO) throws Exception {
        UserInfoDetailVO userInfoDetailVO=loginCompoentService.getUserInfo();
        return screenNoticeService.save(screenNoticeSaveVO,userInfoDetailVO);
    }

    @ApiOperation(value = "获取详情")
    @RequestMapping(value = "detail",method = RequestMethod.GET)
    public BaseResult<ScreenNoticeSaveVO> detail(@RequestParam("id") String id){
        return screenNoticeService.detail(id);
    }

    @ApiOperation(value = "通过id隐藏", notes = "通过id隐藏")
    //@SysLog(.*)
    @PostMapping("/hide")
    @OperLog( systemName = "ZBTZ", description = "TZYC")
    public BaseResult hide(@Valid @RequestBody ScreenMessageDistributeHideDTO screenMessageDistributeHideDTO) {
        if (HideStatusEnum.NOT_HIDED.getValue().equals(screenMessageDistributeHideDTO.getStatus())) {
            return BaseResult.ok(screenNoticeService.hide(screenMessageDistributeHideDTO),"取消隐藏成功");
        }else {
            return BaseResult.ok(screenNoticeService.hide(screenMessageDistributeHideDTO),"隐藏成功");
        }
    }

//    @ApiOperation(value = "批量发布")
//    @RequestMapping(value = "publish",method = RequestMethod.POST)
//    public BaseResult publish(@RequestBody List<String> ids) {
//        UserInfoDetailVO userInfoDetailVO=loginCompoentService.getUserInfo();
//        return screenNoticeService.publish(ids,userInfoDetailVO);
//    }

    @ApiOperation(value = "在这里")
    @RequestMapping(value = "postarticles")
    public BaseResult<postarticlesVO> postarticles(@RequestParam("id") String id, HttpServletResponse response){
        return screenNoticeService.postarticles(id);
    }




}
